<?php
class My_Plugin_Moduleit extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        
    	$menu_module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
        if($menu_module == 'it'){
            
            // connect db cmdb_it
            $_config = new Zend_Config_Ini(CONFIG_PATH . '/application.ini',APPLICATION_ENV);
            $resources2 = $_config->resources2->db2->toArray();
            $parameters['adapter']      = $resources2['adapter'];
            $parameters['host']         = $resources2['params']['host'];
            $parameters['username']     = $resources2['params']['username'];
            $parameters['password']     = $resources2['params']['password'];
            $parameters['dbname']       = $resources2['params']['dbname'];
            $parameters['charset']      = $resources2['params']['charset'];
            //echo '<pre>',print_r($parameters),'</pre>';exit;
            
            try {
                $db = Zend_Db::factory('Pdo_Mysql', $parameters);
                $db->getConnection();
            } catch (Zend_Db_Adapter_Exception $e) {
            
            } catch (Zend_Exception $e) { 
            }
            Zend_Db_Table::setDefaultAdapter($db);
            
            // get layout cmdb_it
            $layout = Zend_Layout::getMvcInstance();
            $layoutsDir = $layout->setLayout('layoutit');    
        }
          
        
    }
}